<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../ajax/jquery-3.4.1.min.js"></script>
    <style>
        #mei {
            width: 100%;
            height: 1000px;
            display: flex;
            background: url(../ajax/bod.a9b05e84.png) no-repeat center;
        }

        #zi {
            width: 200px;
            height: 500px;
            top: 0px;
            left: 0px;
            bottom: 0px;
            right: 0px;
            margin: auto;
        }

        input {
            width: 300px;
            height: 40px;
            border-radius: 10px;
        }

        #miao {
            width: 100px;
            height: 35px;
            background-color: rgb(148, 189, 0);
            border-radius: 10px;
        }

        button {
            width: 50px;
            height: 30px;
            border-radius: 40px;
            margin-left: 110px;
            margin-top: 20px;
        }
    </style>
</head>

<body>
    <div id="mei">
        <div id="zi">
            手机号：<input type="text" id="phone"><br>
            验证码：<input type="text" id="phone_code"><input type="submit" value="请求验证码" id="miao" onclick="ate()"><br>
            邀请码：<input type="text" id="">
            <button id="bbq">登录</button>
        </div>
    </div>
    <script>
        var time = 60;
        var biyang = document.getElementById("miao");
        function ate() {
            var aww = setInterval(function () {
                if (time == 0) {
                    clearInterval(aww);
                    time = 60
                    biyang.setAttribute("value", "请求验证码");
                } else {
                    biyang.setAttribute("value", time + "秒");
                    time--;
                }
            }, 1000);
            $.ajax({
                url: "http://43.143.211.183:8889/sendSms/"+$("#phone").val(),
                type: "get",
                success: function (a) {
                }
            })
        }
        $("#bbq").click(() => {
            $.ajax({
                url: "http://43.143.211.183:8889/login/h5/with-phone-code",
                type: "post",
                data: JSON.stringify({
                    phone: $("#phone").val(),
                    phone_code: $("#phone_code").val(),
                    invite_code: ""
                }),
                contentType: 'application/json',
                success: function (vbn) {
                    console.log(vbn);
                    if (vbn.code == 200) {
                        alert(vbn.message);
                    }
                }
            })
        })
    </script>

</body>

</html>